const { get, post } = require('./http');
const cheerio = require('cheerio');
/**
 * 
 * @param {string} sec_user_id 
 * @param {string} cookie 
 * @param {object} options 
 * @returns 
 */
function get_videos_by_sec_user_id(sec_user_id, cookie, options) {
    let url = 'https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=' + sec_user_id + '&max_cursor=' + 0 + '&count=20';
    const videoList = get(url, {
        headers: {
            "accept": "application/json, text/plain, */*",
            "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
            "cache-control": "no-cache",
            "pragma": "no-cache",
            "sec-ch-ua": "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\"",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": "\"macOS\"",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin",
            "cookie": cookie,
            "Referer": "https://www.douyin.com/user/" + sec_user_id,
            "Referrer-Policy": "strict-origin-when-cross-origin"
        }
    });
    try {
        console.log(videoList);
        const jsonData = JSON.parse(videoList);
        return jsonData;
    } catch (e) {
        console.log('get_videos_by_sec_user_id error');
        console.log(e);
        console.log(videoList);
        return videoList;
    }

}


module.exports = {
    get_videos_by_sec_user_id
}